
var config   = require('./config.js');
var schedule = require("node-schedule");
var request  = require('request');
var site     = config['WEBSITE'];

function FormatNowDate(){
	var mDate = new Date();
	var Y = mDate.getFullYear();
	var M = mDate.getMonth()+1;
	var D = mDate.getDate();
	var H = mDate.getHours();
	var i = mDate.getMinutes();
	var s = mDate.getSeconds();
	return Y +'-' + M + '-' + D + ' ' + H + ':' + i + ':' + s;
}

//定时处理直播
var rule2 = new schedule.RecurrenceRule();

var times2 = [];

for(var i=0; i<60; i++){

    times2.push(i);
    i+=4;
}

rule2.second = times2;
// console.log(times);

var j2 = schedule.scheduleJob(rule2, function(){
    // time=FormatNowDate();
    // console.log("执行任务:"+time);
    uplive();
});


//定期处理订单状态
function uplive(){
    // var time=FormatNowDate();
    // console.log("执行任务setVal"+lastid+'--'+time);
    request(site+"/api/liveback/uplive",function(error, response, body){
        //console.log(error);
        if(error) return;
        if(!body) return;
        // console.log('setVal-body-'+lastid+'--'+time);
        // console.log(body);
    });
    
}